<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script type="text/javascript">
        window.onload = function () {
            var checkBox1 = document.getElementsByTagName("input")[0];
            var btn = document.getElementsByTagName("input")[1];

            function check() {
                if (checkBox1.checked){
                    alert("你喜欢js")
                }else {
                    alert("你不喜欢js")
                }
            }
            btn.onclick = check;
        }

    </script>
</head>
<body>
<p>
    你喜欢js吗？
    <input type="checkbox">
</p>
<p>
    <input type="button" value="提交">
</p>

</body>
</html>